<%@ include file="/common/common.jsp"%>
<%@ page language="java" pageEncoding="UTF-8"%>
<head>
<!--添加弹层效果和layui-->
<script type="text/javascript" src="<%=jsPath%>/layer/layer.js"></script>

<script>
    var index = parent.layer.getFrameIndex(window.name); //获取窗口索引
    $(document).ready(function () {
        try {
            var rowData = parent.$("#oneAdasAlarmData").datagrid("getSelected");
            if (rowData != null) {
                // console.log(rowData);
                showAlarmInfo(rowData);
            }
        } catch (error) {
            console.error("获取报警详细信息错误："+error);
        }
        
    });

    //显示报警信息
    function showAlarmInfo(rowData){
        var alarmNameTemp = Utility.getOneAlarmSourceData(rowData.alarmSource,rowData.alarmType);
        var html = '';
        html+='<tr><td>车牌号码：</td><td>'+rowData.plateNo+'</td><td>车组：</td><td>'+rowData.depName+'</td></tr>';//车牌号车组
        if(alarmNameTemp != null){
            html+='<tr><td>报警来源：</td><td>'+alarmNameTemp.alarmSourceName+'</td><td>报警类型：</td><td>'+alarmNameTemp.alarmTypeName+'</td></tr>';//报警来源和报警类型信息
        }
        html+='<tr><td>报警时间：</td><td colspan="3">'+rowData.alarmTime+'</td></tr>';//报警时间
        var processedUserTemp = (rowData.processedUserName==undefined?"空":rowData.processedUserName);
        var processedTime = (rowData.processedTime==undefined?"空":rowData.processedTime);
        html+='<tr><td>处理结果：</td><td>'+getProcessTypeName(rowData.processed)+'</td><td>处理人员：</td><td>'+processedUserTemp+'</td></tr>';//处理结果，处理人员
        html+='<tr><td>处理时间：</td><td colspan="3">'+processedTime+'</td></tr>';//处理时间
        html+='<tr><td>备注：</td><td colspan="3">'+rowData.processedRemarks+'</td></tr>';//备注
        html+='<tr><td>报警地点：</td><td colspan="3">'+(rowData.location == undefined ? "空" : rowData.location)+'</td></tr>';//报警地点
        html+='<tr><td colspan="4"><input onclick="javascript:btnClose();" type="button" value="关闭" style="width:160px;height:35px;"/></td></tr>';//报警地点
        $("#infoDiv").html(html);
    }

    //根据处理代码获取处理结果描述
    function getProcessTypeName(processed){
        var processedName = "";
        var processTypeListTemp = window.localStorage.getItem("alarmProcessedData");
        processTypeListTemp = JSON.parse(processTypeListTemp);
        //查找处理描述
        if (processTypeListTemp != null) {
            for (var i = 0; i < processTypeListTemp.length; i++) {
                if (processTypeListTemp[i].code == processed) {
                    processedName = processTypeListTemp[i].name;
                    break;
                }
            }
        }
        return processedName;
    }

    //关闭窗口
    function btnClose(){
        parent.layer.close(index);//关闭弹窗
    }

</script>

</head>
<body>
    <table style="width:100%;text-align:center;"class="TableBlock"><tbody id="infoDiv">
        <tr><td colspan="3"></td></tr>
    </tbody></table>
</body>